container.addEventListener("mousemove", function (e) {
  // const x_point = e.pageX;
  // const y_point = e.pageY;
  // if (websocket.readyState == WebSocket.OPEN) {
  //   websocket.send(
  //     JSON.stringify({
  //       type: "gun",
  //       id: player_tank.id,
  //       x: x_point,
  //       y: y_point,
  //     })
  //   );
  // }
  const x_point = e.pageX
  const y_point = e.pageY
  player_tank.updateTankGunRotate([x_point, y_point])
});

container.addEventListener("mousedown", function () {
  const bullet = player_tank.fire()
  if (bullet) {
    all_bullet.set(bullet.id, bullet)
  }
});

window.addEventListener("keydown", function (key) {
  if (key.key === "w") {
    player_tank.orientation.top = true;
  }
  if (key.key === "a") {
    player_tank.orientation.left = true;
  }
  if (key.key === "s") {
    player_tank.orientation.bottom = true;
  }
  if (key.key === "d") {
    player_tank.orientation.right = true;
  }

//   if (key.key === "ArrowUp") {
//     computer_tank_1.orientation.top = true;
//   }
//   if (key.key === "ArrowLeft") {
//     computer_tank_1.orientation.left = true;
//   }
//   if (key.key === "ArrowDown") {
//     computer_tank_1.orientation.bottom = true;
//   }
//   if (key.key === "ArrowRight") {
//     computer_tank_1.orientation.right = true;
//   }
});

window.addEventListener("keyup", function (key) {
  if (key.key === "w") {
    player_tank.orientation.top = false;
  }
  if (key.key === "a") {
    player_tank.orientation.left = false;
  }
  if (key.key === "s") {
    player_tank.orientation.bottom = false;
  }
  if (key.key === "d") {
    player_tank.orientation.right = false;
  }

//   if (key.key === "ArrowUp") {
//     computer_tank_1.orientation.top = false;
//   }
//   if (key.key === "ArrowLeft") {
//     computer_tank_1.orientation.left = false;
//   }
//   if (key.key === "ArrowDown") {
//     computer_tank_1.orientation.bottom = false;
//   }
//   if (key.key === "ArrowRight") {
//     computer_tank_1.orientation.right = false;
//   }
});
